<?php

require_once './include/common.inc.php';

$page_title = 'jans2en furniture - Login - Request an Authorized Dealer Account';

$postiondiv='<div class="position"><a href="index.php">首页</a> &gt; <span class="position"> 用户注册</span></div>';

$baner_img='<div class="bigtitle">Register</div>';

getMyParam('act');
$register_is_ok = false;

if ($act == "register") {
    getMyParam('dealerinquirycompany');
    getMyParam('dealerinquiryfirstname');
    getMyParam('dealerinquirylastname');
    getMyParam('dealerinquirybusinesstype');
    //getMyParam('dealerinquiryyearsinbusiness');
    getMyParam('dealerinquiryaddress');
    //getMyParam('dealerinquiryaddress2');
    getMyParam('dealerinquirycity');
    //getMyParam('stateid');
    getMyParam('countryid');
    //getMyParam('dealerinquirypostal');
    getMyParam('dealerinquiryphone');
    //getMyParam('dealerinquiryfax');
	getMyParam('dealerinquiryemail');
    //getMyParam('dealerinquiryregistrationnumber');
    getMyParam('dealerinquiryurl');
    getMyParam('find_us_content');
    //getMyParam('comments');
    getMyParam('company_content');
	getMyParam('from');
	



	$nulls="";
 
	$sql = "SELECT `id`, `username`, `email` FROM `user` WHERE `email` = '$dealerinquiryemail' AND `status` <>3";
    $rs = $db->get_one($sql);
    if (!empty($rs)) {
		//echo $dealerinquiryemail;
        echo "<script>alert('Email exist.');history.back(1);</script>";
        exit;
    }

	if (trim($dealerinquirycompany) == "" || trim($dealerinquiryphone) == "" || trim($dealerinquiryemail) == "" || $dealerinquirycountryid == 0  || trim($dealerinquirycity) == "" || trim($dealerinquiryaddress) == "" ) {
        echo "<script>alert('Please enter content.');history.back(1);</script>";
        exit;
	} else {
		/*$sql = "INSERT INTO `user` (`firstname` , `lastname` , `company` , `business_type` , `business_year` , `address` , `address2` , `city` , `stateid` , `countryid` , `zip` , `phone` , `fax` , `email` , `company_number` , `url` , `find_us_content` , `comments` , `company_content`, `regtime`  )
				VALUES (
				'$dealerinquiryfirstname', '$dealerinquirylastname', '$dealerinquirycompany', '$dealerinquirybusinesstype', '$dealerinquiryyearsinbusiness', '$dealerinquiryaddress', '$dealerinquiryaddress2', '$dealerinquirycity', '$stateid', '$countryid', '$dealerinquirypostal', '$dealerinquiryphone', '$dealerinquiryfax', '$dealerinquiryemail', '$dealerinquiryregistrationnumber', '$dealerinquiryurl', '$find_us_content', '$comments', '$company_content','$timestamp'
				)";*/
				
						
		$sql = "INSERT INTO `user` (`firstnamezh` , `lastname` , `companyzh` , `business_type` , `addresszh` , `cityzh`  , `countryid` , `phone`, `email` ,  `url` , `find_us_contentzh` , `company_contentzh`, `regtime`,`from`  )
				VALUES (
				'$dealerinquiryfirstname', '$nulls', '$dealerinquirycompany', '$dealerinquirybusinesstype', '$dealerinquiryaddress', '$dealerinquirycity', '$countryid', '$dealerinquiryphone', '$dealerinquiryemail',  '$dealerinquiryurl', '$find_us_content', '$company_content','$timestamp',$from
				)";
	//	echo $sql;
	    $db->query($sql);

       //edit by martin 2010 - 12 -23
       // require_once './mail/register_to_dealer.php';
      //  sendmail($from_name,$from_email,$to_name,$to_email,$subject,$content);
		
        $system_ary = getSystemValue("");
		$webmaster_name = $system_ary['webmaster_namezh'];
		$webmaster_email = $system_ary['webmaster_emailzh'];
        require_once './mail/register_to_webmaster.php';        
		sendmail($from_name,$from_email,$to_name,$to_email,$subject,$content);
        header("location:register.php?act=succeed");
        exit;
    }
}

if ($act == "succeed") {
    $register_is_ok = true;
}

//foreach ($STATE_ARY as $k=>$v) {
//    $state_select .= '<option value="' . $k . '" >' . $v . '</option>';
//    if ($k==51) {
//        $state_select .= '<option value="">--------------------------</option><option value="">CANADIAN PROVINCES</option><option value="">--------------------------</option>';
//    }
//}
foreach ($COUNTRY_ARY as $k=>$v) {
    $country_select .= '<option value="' . $k . '" >' . $v . '</option>';
}

// -------------- guideͼƬ start ----------------------------------------
$img = getSystemValue("picture_other_registeren");

if (trim($img) == "" || !file_exists("attachments/system/" . $img)) {
	$img = 'attachments/noCN.gif';
} 
else
{
	$img = 'attachments/system/'.$img;	
}
// -------------- guideͼƬ end ----------------------------------------

require_once PrintEot('header');
require_once PrintEot('register');
require_once PrintEot('footer');

?>
